package com.serviceImpl;

import com.javabean.Role;
import com.javabean.RolePermission;
import com.mapper.RoleMapper;
import com.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    RoleMapper roleMapper;
    @Override
    public List<Role> findAll() {
        return roleMapper.selectAll();
    }

    @Override
    public void add(Role role) {
        roleMapper.insertRole(role);
    }

    @Override
    public void deleteById(int id) {
        roleMapper.deleteById(id);
    }

    @Override
    public Role show(int id) {
        return roleMapper.selectR_P(id);
    }

    @Override
    public void edit(Role role) {
        roleMapper.updateRole(role);
    }

    @Override
    public void permissionAdd(RolePermission rolePermission) {
        roleMapper.deleteByRid(rolePermission.getRid());
        roleMapper.insertR_P(rolePermission);
    }
}